<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Role;
use Spatie\Permission\Models\Permission;

class InitRolePermissionSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $role = Role::updateOrCreate(['name' => '超级管理员'], [ 'guard_name' => 'api']);
        $role = Role::updateOrCreate(['name' => '一级管理员'], [ 'guard_name' => 'api']);
        $role = Role::updateOrCreate(['name' => '普通管理员'], [ 'guard_name' => 'api']);
        $role = Role::updateOrCreate(['name' => '操作人员'], [ 'guard_name' => 'api']);
        $role->givePermissionTo(Permission::all()->where(['guard_name' => 'api']));
    }
}
